{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Since we don't want to install plotly on the CI, we can test with a custom mime type.\n",
    "# The mime type application/vnd.custom should end up getting rendered as an individual output in the cell (instead of letting the Output Widget handle it - which it cannot).\n",
    "\n",
    "import ipywidgets as widgets\n",
    "from ipywidgets import interact\n",
    "import IPython.display\n",
    "\n",
    "\n",
    "def update_graph(txt):\n",
    "    print(f\"Text Value is {txt}\")\n",
    "    display({\"application/vnd.custom\": f\"Text Value is {txt}\"}, raw=True)\n",
    "\n",
    "\n",
    "text = widgets.Text(value='Foo')\n",
    "interact(update_graph, txt=text)\n",
    "update_graph(\"Hello World\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# This is a real world example.\n",
    "\n",
    "import ipywidgets as widgets\n",
    "from ipywidgets import interact\n",
    "import pandas as pd\n",
    "import plotly.express as px\n",
    "pd.options.plotting.backend = \"plotly\"\n",
    "\n",
    "def update_graph(rng):\n",
    "    df = pd.DataFrame({\"x\": list(range(*rng)), \"y\": list(range(*rng))})\n",
    "    fig = df.plot.scatter(x=\"x\", y=\"y\")\n",
    "    fig.show()\n",
    "\n",
    "slider=widgets.IntRangeSlider(value=(0, 10), min=0, max=20, description='Hello')\n",
    "interact(update_graph, rng=slider)\n",
    "update_graph([0, 10])\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
